import type { App } from 'vue'

import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'

import { useRootStore } from '@/store/root'
import { useAppStore } from '@/store/modules/app'
import { useBasicListStore } from '@/store/modules/basic-list'
import { useRouteStore } from '@/store/modules/route'
import { useUserStore } from '@/store/modules/user'

const pinia = createPinia()
pinia.use(createPersistedState({
  storage: window.sessionStorage,
}))

const store = {
  useRootStore,
  useAppStore,
  useBasicListStore,
  useRouteStore,
  useUserStore
}

export function setupStore(app: App) {
  app.use(pinia)
}

export default store
